package 第二类.service.impl;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.springframework.stereotype.Service;
import 第二类.domain.Administrator;
import 第二类.domain.User;
import 第二类.mapper.UserMapper;
import 第二类.service.UserService;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

@Service("UserService")
public class UserServiceImpl implements UserService {
    private InputStream resourceAsStream = Resources.getResourceAsStream("SqlMapConfig.xml");
    private SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(resourceAsStream);
    private SqlSession sqlSession = sqlSessionFactory.openSession();
    private UserMapper mapper = sqlSession.getMapper(UserMapper.class);

    public UserServiceImpl() throws IOException {

    }

    @Override
    public List<User> findAll() throws IOException {

        List<User> list=mapper.findAll();
        return list;
    }

    @Override
    public List<User> findUser(User user) {
        List<User> user1 = mapper.findUser(user);

        return user1;
    }

    @Override
    public void findAdd(User user) {
        mapper.findAdd(user);
    }

    @Override
    public void SelectUser(User user) {
        mapper.SelectUser(user);
    }


}
